package com.buka.controller;

import com.buka.entity.Hotel;
import com.buka.service.HotelService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/index")//url映射
public class IndexServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //需要查询未入住的房屋，当前在controller层，需要使用service层对象，查询数据
        HotelService hotelService = new HotelService();
        List<Hotel> list = hotelService.noInList();
        //数据集合需要交给jsp 渲染  jsp （view层  mvc）
        req.setAttribute("rl", list);
        req.getRequestDispatcher("/index.jsp").forward(req, resp);


    }
}
